package com.stox.core.ui.swing.event.listener;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;

import javax.swing.JInternalFrame;

import com.stox.core.ui.swing.view.InternalFrameView;
import com.stox.core.ui.swing.widget.MainFrame;

public class IconifiedOnTopListener implements VetoableChangeListener{
	@Override
	public void vetoableChange(PropertyChangeEvent ev)
			throws PropertyVetoException {
	 String name = ev.getPropertyName();
      if (name.equals(JInternalFrame.IS_ICON_PROPERTY)) {
    	  if(ev.getNewValue() == Boolean.TRUE){
    		  MainFrame.getInstance().getDesktop().moveToFront((InternalFrameView)ev.getSource());
    	  }else{
    		  MainFrame.getInstance().getDesktop().moveToBack((InternalFrameView)ev.getSource());
    	  }
      }
	}
}